<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of tt_x</title>
  <meta name="keywords" content="tt_x">
  <meta name="description" content="Computes X in the QTT-format">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="#">tt2</a> &gt; <a href="index.html">core</a> &gt; tt_x.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for tt2/core&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>tt_x
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>Computes X in the QTT-format</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [res]=tt_x(n,varargin) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">Computes X in the QTT-format
   [RES]=TT_X(N,D), or [RES]=TT_X(N): Vector with elements 
   0:N(1)*...*N(D)-1 is transformed into a tensor of size 
   N(1) x N(2) x ... x N(D)
   This function returns its TT-decomposition with rank 2
   This function is useful for the computation of the QTT-decomposition
   of the function y=x


 TT-Toolbox 2.2, 2009-2012

This is TT Toolbox, written by Ivan Oseledets et al.
Institute of Numerical Mathematics, Moscow, Russia
webpage: http://spring.inm.ras.ru/osel

For all questions, bugs and suggestions please mail
ivan.oseledets@gmail.com
---------------------------</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/@tt_tensor/tt_tensor.html" class="code" title="function t = tt_tensor(varargin)">tt_tensor</a>	TT-tensor constructor</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../../tt2/tests/test_cross.html" class="code" title="">test_cross</a>	Simple function to test the cross method</li><li><a href="../../tt2/tests/test_cross2.html" class="code" title="">test_cross2</a>	Simple function to test the cross method</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [res]=tt_x(n,varargin)</a>
0002 <span class="comment">%Computes X in the QTT-format</span>
0003 <span class="comment">%   [RES]=TT_X(N,D), or [RES]=TT_X(N): Vector with elements</span>
0004 <span class="comment">%   0:N(1)*...*N(D)-1 is transformed into a tensor of size</span>
0005 <span class="comment">%   N(1) x N(2) x ... x N(D)</span>
0006 <span class="comment">%   This function returns its TT-decomposition with rank 2</span>
0007 <span class="comment">%   This function is useful for the computation of the QTT-decomposition</span>
0008 <span class="comment">%   of the function y=x</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%</span>
0011 <span class="comment">% TT-Toolbox 2.2, 2009-2012</span>
0012 <span class="comment">%</span>
0013 <span class="comment">%This is TT Toolbox, written by Ivan Oseledets et al.</span>
0014 <span class="comment">%Institute of Numerical Mathematics, Moscow, Russia</span>
0015 <span class="comment">%webpage: http://spring.inm.ras.ru/osel</span>
0016 <span class="comment">%</span>
0017 <span class="comment">%For all questions, bugs and suggestions please mail</span>
0018 <span class="comment">%ivan.oseledets@gmail.com</span>
0019 <span class="comment">%---------------------------</span>
0020 <span class="keyword">if</span> (numel(n) == 1)
0021   d=varargin{1}; 
0022   n=n*ones(1,d);
0023 <span class="keyword">else</span>
0024   d=numel(n);
0025 <span class="keyword">end</span>
0026 
0027 
0028 
0029 res=cell(d,1);
0030 
0031 res{1}=ones(n(1),2);
0032 res{1}(:,1)=0:n(1)-1;
0033 
0034 <span class="comment">% shabl=zeros(n(1),2,2);</span>
0035 <span class="comment">% for j=1:n</span>
0036 <span class="comment">%     shabl(j,:,:)=eye(2,2);</span>
0037 <span class="comment">% end</span>
0038 ni=n(1);
0039 
0040 <span class="keyword">for</span> i=2:d-1
0041     shabl=zeros(n(i),2,2);
0042     <span class="keyword">for</span> j=1:n(i)
0043         shabl(j,:,:)=eye(2,2);
0044     <span class="keyword">end</span>
0045 
0046     res{i}=shabl;
0047     res{i}(:,2,1)=ni.*(0:n(i)-1);
0048     ni=ni*n(i);
0049 <span class="keyword">end</span>
0050 
0051 res{d}=ones(n(d),2);
0052 res{d}(:,2)=ni.*(0:n(d)-1);
0053 
0054 res = <a href="../../tt2/@tt_tensor/tt_tensor.html" class="code" title="function t = tt_tensor(varargin)">tt_tensor</a>(res); <span class="comment">% Bydlocode</span>
0055 <span class="keyword">return</span>
0056 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Wed 08-Feb-2012 18:20:24 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>